<?php

declare (strict_types=1);

namespace App\Model;

use Hyperf\Database\Model\Events\Saving;
use Hyperf\Database\Model\Relations\HasOne;

/**
 * @property int $id
 * @property int $is_reservation 是否开启定做 1是0否
 * @property int $shop_id 商户id
 * @property int $has_rooms 有无包间1有0无
 * @property int $min_number 起订人数
 * @property int $latest_reserve_day 最晚可预定天数后得座位
 * @property int $deposit_type 定金类型1、免费2、按人数设定3、按订单设置
 * @property string $down_payment_yuan 预付定金（元）定金类型来设置2、就是该数据*人数
 * @property int $refund_type 退款类型1、按预定时间2、未就餐随时可退
 * @property int $refundable_time_minute 预定时间前多少分钟可退（分）
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 * @property string $deleted_at 删除时间（不会有）
 * @property string $extend 扩展字段 以防万一
 */
class FlyGourmetReservationConf extends Model
{

    /**
     * 默认属性
     * @var array
     */
    protected $attributes = [
        'is_reservation' => false,
        'has_rooms' => false,
        'min_number' => 0,
        'latest_reserve_day' => 0,
        'deposit_type' => 1,
        'down_payment_yuan' => 0,
        'refund_type' => 2,
        'refundable_time_minute' => 0,
        'extend' => ""
    ];


    /**
     * 定金类型
     */
    const DEPOSIT_TYPE_FREE = 1; //免费

    const DEPOSIT_TYPE_PEOPLE = 2; //人数

    const DEPOSIT_TYPE_ORDER = 3; //订单

    /**
     * 退款类型1
     */
    const REFUND_TYPE_SCHEDULT_TIME = 1; //按预定时间

    const REFUND_TYPE_RETUTNABLE = 2; //未就餐随时可退


    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'fly_gourmet_reservation_conf';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'is_reservation', 'shop_id', 'has_rooms', 'min_number', 'latest_reserve_day', 'deposit_type', 'down_payment_yuan', 'refund_type', 'refundable_time_minute', 'created_at', 'updated_at', 'deleted_at', 'extend'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'is_reservation' => 'boolean', 'shop_id' => 'integer', 'has_rooms' => 'boolean', 'min_number' => 'integer', 'latest_reserve_day' => 'integer', 'deposit_type' => 'integer', 'refund_type' => 'integer', 'refundable_time_minute' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    /**
     * 获取店铺信息
     * @return HasOne
     */
    public function with_shop_info()
    {
        return $this->hasOne(FlyShop::class, 'id', 'shop_id');
    }
}